package com.doge.service.wx.issue;

import com.doge.bean.pojo.issue.Issue;
import com.doge.bean.pojo.issue.IssueExample;
import com.doge.bean.vo.issue.WxIssueListVo;
import com.doge.mapper.IssueMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: doge
 * @description: 帮助中心服务
 * @author: Mr.Jiang
 * @create: 2021-12-04 09:30
 **/
@Service
public class WxIssueServiceImpl implements WxIssueService{
    @Autowired
    IssueMapper issueMapper;
    @Override
    public WxIssueListVo list(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        IssueExample issueExample = new IssueExample();
        issueExample.createCriteria().andDeletedEqualTo(false);
        List<Issue> issues = issueMapper.selectByExample(issueExample);
        PageInfo pageInfo = new PageInfo(issues);
        WxIssueListVo wxIssueListVo = new WxIssueListVo();
        wxIssueListVo.setLimit(limit);
        wxIssueListVo.setList(issues);
        wxIssueListVo.setPage(page);
        wxIssueListVo.setPages(pageInfo.getPages());
        wxIssueListVo.setTotal((int) pageInfo.getTotal());
        return wxIssueListVo;
    }
}
